﻿@using MvcApplicationTest.Controllers
@using MvcApplicationTest.Models
@model UserOrderInfoModel
@{
    ViewBag.Title = "Please Order.";
}


<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <div>
        <hgroup class="title">
            <h2>@ViewBag.Title</h2>
        </hgroup>
        <div>
            <table>
                <tr>
                    <td>
                        <div>
                            @using (Html.BeginForm())
                            {
                                <fieldset>
                                    <legend>Log in Form</legend>
                                    <ol>
                                        <li>
                                            @Html.LabelFor(m => m.Orders)
                                            @Html.HiddenFor(m => m.HiddenValue)
                                            @Utility.CheckBoxListFor("CheckBoxList", Model.Orders)
                                        </li>
                                    </ol>
                                    <input type="submit" value="Ok" onclick="GetCheckBoxList()"/>
                                </fieldset>
                            }
                        </div>
                        <div>
                            <h2>Your balance:</h2>
                            @ViewBag.Balance
                        </div>
                    </td>
                    <td>
                        <!--<img src="../../Images/IMG_20130718_085014.jpg"  alt="hehe" />-->
                        @*@Utility.GetOrderPicture(ViewBag.OrderPicture)*@

                    </td>
                </tr>

            </table>


        </div>
    </div>

    <aside>
    <h3>Return:</h3>
    <ul>
        <li>@Html.ActionLink("Order Now", "OrderPage", "Home")</li>
        <li>@Html.ActionLink("Today's Order", "OrderResult", "Home")</li>
        <li>@Html.ActionLink("Order History", "OrderHistory", "Home")</li>
        <li>@Html.ActionLink("Change Your Information", "Register", "Account", new { id = "CYI" }, null)</li>
    </ul>
</aside>
</body>

<script type="text/javascript">
    function GetCheckBoxList() {
        var obj = [];
        var $checkBoxList = $("input[name=CheckBoxList]");
        for (var i = 0; i < $checkBoxList.length; i++) {
            if ($checkBoxList[i].checked) {
                //HiddenValue为string[]时，不好用
                //$("#HiddenValue").push($checkBoxList[i].value + "|" + $checkBoxList[i].text);
                obj.push($checkBoxList[i].value + "|" + $($checkBoxList[i]).attr("cost"));
            }
        }
        $("#HiddenValue").val(obj.join());
    }

    //如何手动连到controller中的action

</script>
</html>

